#include "lolevel.h"
#include "platform.h"
#include "core.h"
#include "conf.h"

//found at ROM:FFD18E60
static long *nrflag = (long*)0x6690;

#include "../../../generic/capt_seq.c"

void __attribute__((naked,noinline)) capt_seq_task() {
 asm volatile (
                 "STMFD   SP!, {R3-R7,LR}\n"
                 "LDR     R7, =0x13C94\n"
                 "LDR     R6, =0x2AD0\n"
 "loc_FFC4F64C:\n"
                 "LDR     R0, [R6,#4]\n"
                 "MOV     R2, #0\n"
                 "MOV     R1, SP\n"
                 "BL      sub_FFC1659C\n"
                 "TST     R0, #1\n"
                 "BEQ     loc_FFC4F678\n"
                 "LDR     R1, =0x5B4\n"
                 "LDR     R0, =0xFFC4EF30\n"	// aSsshoottask_c
                 "BL      sub_FFC0B048\n"	// DebugAssert
                 "BL      sub_FFC0B000\n"	// eventproc_export_ExitTask
                 "LDMFD   SP!, {R3-R7,PC}\n"
 "loc_FFC4F678:\n"
                 "LDR     R0, [SP]\n"
                 "LDR     R1, [R0]\n"
                 "CMP     R1, #0x21\n"
                 "ADDLS   PC, PC, R1,LSL#2\n"
                 "B       loc_FFC4F8AC\n"
 "loc_FFC4F68C:\n"
                 "B       loc_FFC4F714\n"
 "loc_FFC4F690:\n"
                 "B       loc_FFC4F71C\n"
 "loc_FFC4F694:\n"
                 "B       loc_FFC4F744\n"
 "loc_FFC4F698:\n"
                 "B       loc_FFC4F758\n"
 "loc_FFC4F69C:\n"
                 "B       loc_FFC4F750\n"
 "loc_FFC4F6A0:\n"
                 "B       loc_FFC4F760\n"
 "loc_FFC4F6A4:\n"
                 "B       loc_FFC4F768\n"
 "loc_FFC4F6A8:\n"
                 "B       loc_FFC4F774\n"
 "loc_FFC4F6AC:\n"
                 "B       loc_FFC4F7CC\n"
 "loc_FFC4F6B0:\n"
                 "B       loc_FFC4F758\n"
 "loc_FFC4F6B4:\n"
                 "B       loc_FFC4F7D4\n"
 "loc_FFC4F6B8:\n"
                 "B       loc_FFC4F7E0\n"
 "loc_FFC4F6BC:\n"
                 "B       loc_FFC4F7E8\n"
 "loc_FFC4F6C0:\n"
                 "B       loc_FFC4F7F0\n"
 "loc_FFC4F6C4:\n"
                 "B       loc_FFC4F7F8\n"
 "loc_FFC4F6C8:\n"
                 "B       loc_FFC4F800\n"
 "loc_FFC4F6CC:\n"
                 "B       loc_FFC4F808\n"
 "loc_FFC4F6D0:\n"
                 "B       loc_FFC4F810\n"
 "loc_FFC4F6D4:\n"
                 "B       loc_FFC4F818\n"
 "loc_FFC4F6D8:\n"
                 "B       loc_FFC4F820\n"
 "loc_FFC4F6DC:\n"
                 "B       loc_FFC4F828\n"
 "loc_FFC4F6E0:\n"
                 "B       loc_FFC4F830\n"
 "loc_FFC4F6E4:\n"
                 "B       loc_FFC4F838\n"
 "loc_FFC4F6E8:\n"
                 "B       loc_FFC4F844\n"
 "loc_FFC4F6EC:\n"
                 "B       loc_FFC4F84C\n"
 "loc_FFC4F6F0:\n"
                 "B       loc_FFC4F858\n"
 "loc_FFC4F6F4:\n"
                 "B       loc_FFC4F860\n"
 "loc_FFC4F6F8:\n"
                 "B       loc_FFC4F868\n"
 "loc_FFC4F6FC:\n"
                 "B       loc_FFC4F870\n"
 "loc_FFC4F700:\n"
                 "B       loc_FFC4F878\n"
 "loc_FFC4F704:\n"
                 "B       loc_FFC4F880\n"
 "loc_FFC4F708:\n"
                 "B       loc_FFC4F888\n"
 "loc_FFC4F70C:\n"
                 "B       loc_FFC4F894\n"
 "loc_FFC4F710:\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F714:\n"
                 "BL      sub_FFC4FF14\n"
		 "BL      shooting_expo_param_override\n"	//------------>
                 "B       loc_FFC4F76C\n"
 "loc_FFC4F71C:\n"
                 "MOV     R0, #0xC\n"
                 "BL      sub_FFC541E4\n"
                 "TST     R0, #1\n"
                 "LDR     R0, [SP]\n"
                 "MOVNE   R1, #1\n"
                 "LDRNE   R2, [R0,#0xC]\n"
                 "MOVNE   R0, #1\n"
                 "BNE     loc_FFC4F7C4\n"
                 "BL      sub_FFC4EFE8_my\n"			//------------>
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F744:\n"
                 "MOV     R0, #1\n"
                 "BL      sub_FFC50154\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F750:\n"
                 "BL      sub_FFC4FBE0\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F758:\n"
                 "BL      sub_FFC4FEF4\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F760:\n"
                 "BL      sub_FFC4FEFC\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F768:\n"
                 "BL      sub_FFC50074\n"
 "loc_FFC4F76C:\n"
                 "BL      sub_FFC4D318\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F774:\n"
                 "LDR     R4, [R0,#0xC]\n"
                 "BL      sub_FFC4FF04\n"
                 "MOV     R0, R4\n"
                 "BL      sub_FFD17BE4\n"
                 "TST     R0, #1\n"
                 "MOV     R5, R0\n"
                 "BNE     loc_FFC4F7B4\n"
                 "BL      sub_FFC60E70\n"
                 "STR     R0, [R4,#0x18]\n"
                 "MOV     R0, R4\n"
                 "BL      sub_FFD18D84\n"
                 "MOV     R0, R4\n"
                 "BL      sub_FFD19150\n"
                 "MOV     R5, R0\n"
                 "LDR     R0, [R4,#0x18]\n"
                 "BL      sub_FFC61074\n"
 "loc_FFC4F7B4:\n"
                 "BL      sub_FFC4FEF4\n"
                 "MOV     R2, R4\n"
                 "MOV     R1, #9\n"
                 "MOV     R0, R5\n"
 "loc_FFC4F7C4:\n"
                 "BL      sub_FFC4D7DC\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F7CC:\n"
                 "BL      sub_FFC500D4\n"
                 "B       loc_FFC4F76C\n"
 "loc_FFC4F7D4:\n"
                 "LDR     R0, [R7,#0x4C]\n"
                 "BL      sub_FFC50660\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F7E0:\n"
                 "BL      sub_FFC50908\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F7E8:\n"
                 "BL      sub_FFC5099C\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F7F0:\n"
                 "BL      sub_FFD17E0C\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F7F8:\n"
                 "BL      sub_FFD18004\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F800:\n"
                 "BL      sub_FFD18088\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F808:\n"
                 "BL      sub_FFD18168\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F810:\n"
                 "BL      sub_FFD18228\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F818:\n"
                 "MOV     R0, #0\n"
                 "B       loc_FFC4F83C\n"
 "loc_FFC4F820:\n"
                 "BL      sub_FFD185E8\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F828:\n"
                 "BL      sub_FFD18678\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F830:\n"
                 "BL      sub_FFD18738\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F838:\n"
                 "MOV     R0, #1\n"
 "loc_FFC4F83C:\n"
                 "BL      sub_FFD18498\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F844:\n"
                 "BL      sub_FFC502FC\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F84C:\n"
                 "BL      sub_FFC50328\n"
                 "BL      sub_FFC4F9E4\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F858:\n"
                 "BL      sub_FFD18370\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F860:\n"
                 "BL      sub_FFD18408\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F868:\n"
                 "BL      sub_FFC4EEC0\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F870:\n"
                 "BL      sub_FFC14638\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F878:\n"
                 "BL      sub_FFC528BC\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F880:\n"
                 "BL      sub_FFC52918\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F888:\n"
                 "BL      sub_FFC52974\n"
                 "BL      sub_FFC52934\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F894:\n"
                 "LDRH    R0, [R7,#0x98]\n"
                 "CMP     R0, #4\n"
                 "BNE     loc_FFC4F8B8\n"
                 "BL      sub_FFC52918\n"
                 "BL      sub_FFC52D60\n"
                 "B       loc_FFC4F8B8\n"
 "loc_FFC4F8AC:\n"
                 "LDR     R1, =0x709\n"
                 "LDR     R0, =0xFFC4EF30\n"	// aSsshoottask_c
                 "BL      sub_FFC0B048\n"	// DebugAssert
 "loc_FFC4F8B8:\n"
                 "LDR     R0, [SP]\n"
                 "LDR     R1, [R0,#4]\n"
                 "LDR     R0, [R6]\n"
                 "BL      sub_FFC58E7C\n"
                 "LDR     R4, [SP]\n"
                 "LDR     R0, [R4,#8]\n"
                 "CMP     R0, #0\n"
                 "LDREQ   R1, =0x132\n"
                 "LDREQ   R0, =0xFFC4EF30\n"	// aSsshoottask_c
                 "BLEQ    sub_FFC0B048\n"	// DebugAssert
                 "MOV     R0, #0\n"
                 "STR     R0, [R4,#8]\n"
                 "B       loc_FFC4F64C\n"
    );
} 


void __attribute__((naked,noinline)) sub_FFC4EFE8_my(){
    asm volatile(
                 "STMFD   SP!, {R3-R7,LR}\n"
                 "LDR     R4, [R0,#0xC]\n"
                 "LDR     R5, =0x13C94\n"
                 "LDR     R0, [R4,#8]\n"
                 "ORR     R0, R0, #1\n"
                 "STR     R0, [R4,#8]\n"
                 "LDRH    R0, [R5,#0x96]\n"
                 "CMP     R0, #3\n"
                 "BEQ     loc_FFC4F0B8\n"
                 "LDR     R0, [R4,#0xC]\n"
                 "CMP     R0, #1\n"
                 "BLS     loc_FFC4F068\n"
                 "LDRH    R0, [R5,#0x94]\n"
                 "CMP     R0, #0\n"
                 "BNE     loc_FFC4F0B8\n"
                 "LDRH    R0, [R5,#0x90]\n"
                 "CMP     R0, #2\n"
                 "BNE     loc_FFC4F074\n"
                 "BL      sub_FFC503E4\n"
                 "LDRH    R0, [R5,#0x96]\n"
                 "CMP     R0, #3\n"
                 "BEQ     loc_FFC4F0B8\n"
                 "LDR     R0, [R4,#0xC]\n"
                 "CMP     R0, #1\n"
                 "BLS     loc_FFC4F068\n"
                 "LDRH    R0, [R5,#0x94]\n"
                 "CMP     R0, #0\n"
                 "BNE     loc_FFC4F0B8\n"
                 "LDRH    R0, [R5,#0x90]\n"
                 "CMP     R0, #2\n"
                 "BEQ     loc_FFC4F098\n"
                 "B       loc_FFC4F074\n"
 "loc_FFC4F068:\n"
                 "LDRH    R0, [R5,#0x94]\n"
                 "CMP     R0, #0\n"
                 "BNE     loc_FFC4F0B8\n"
 "loc_FFC4F074:\n"
                 "LDRH    R0, [R5,#0x90]\n"
                 "CMP     R0, #1\n"
                 "BNE     loc_FFC4F0B8\n"
                 "LDR     R0, [R4,#0xC]\n"
                 "CMP     R0, #1\n"
                 "BLS     loc_FFC4F0B8\n"
                 "LDR     R0, [R4,#0x10]\n"
                 "CMP     R0, #1\n"
                 "BNE     loc_FFC4F0B8\n"
 "loc_FFC4F098:\n"
                 "LDR     R3, =0x269\n"
                 "LDR     R0, =0x2AD0\n"
                 "STR     R3, [SP]\n"
                 "LDR     R0, [R0]\n"
                 "LDR     R2, =0xEA60\n"
                 "LDR     R3, =0xFFC4EF30\n"	// aSsshoottask_c
                 "MOV     R1, #0x40000000\n"
                 "BL      sub_FFC54530\n"
 "loc_FFC4F0B8:\n"
                 "BL      sub_FFC4EEC0\n"
                 "MOV     R0, #2\n"
                 "BL      sub_FFC4BB58\n"
                 "BL      sub_FFC4FF04\n"
                 "MOV     R0, R4\n"
                 "BL      sub_FFC50284\n"
                 "MOV     R0, R4\n"
                 "BL      sub_FFD17804\n"
                 "CMP     R0, #0\n"
                 "MOV     R0, R4\n"
                 "BEQ     loc_FFC4F100\n"
                 "BL      sub_FFD178E4\n"
                 "TST     R0, #1\n"
                 "MOVNE   R2, R4\n"
                 "LDMNEFD SP!, {R3-R7,LR}\n"
                 "MOVNE   R1, #1\n"
                 "BNE     sub_FFC4D7DC\n"
                 "B       loc_FFC4F104\n"
 "loc_FFC4F100:\n"
                 "BL      sub_FFD17878\n"
 "loc_FFC4F104:\n"
                 "MOV     R0, #0\n"
                 "STR     R0, [SP]\n"
                 "LDRH    R0, [R5,#0x96]\n"
                 "MOV     R2, #2\n"
                 "MOV     R1, SP\n"
                 "CMP     R0, #3\n"
                 "LDRNE   R0, [R4,#0xC]\n"
                 "CMPNE   R0, #1\n"
                 "MOVHI   R0, #1\n"
                 "STRHI   R0, [SP]\n"
                 "LDR     R0, =0x127\n"
                 "BL      sub_FFC60BE4\n"
                 "BL      sub_FFD39CAC\n"
                 "BL      sub_FFC60E70\n"
                 "STR     R0, [R4,#0x18]\n"
                 "MOV     R0, R4\n"
                 "BL      sub_FFD18D84\n"
                 "BL      sub_FFD197CC\n"
                 "MOV     R0, R4\n"
                 "BL      sub_FFD18E4C_my\n"		//-------------------->
                 "MOV     R6, R0\n"
                 "BL      capt_seq_hook_raw_here\n"	// added
                 "BL      sub_FFC52918\n"
                 "BL      sub_FFC52960\n"
                 "BL      sub_FFC529A0\n"
                 "MOV     R2, R4\n"
                 "MOV     R1, #1\n"
                 "MOV     R0, R6\n"
                 "BL      sub_FFC4D7DC\n"
                 "BL      sub_FFD190F4\n"
                 "CMP     R0, #0\n"
                 "LDRNE   R0, [R4,#8]\n"
                 "ORRNE   R0, R0, #0x2000\n"
                 "STRNE   R0, [R4,#8]\n"
                 "LDRH    R0, [R5,#0x96]\n"
                 "CMP     R0, #3\n"
                 "BEQ     locret_FFC4F1B0\n"
                 "LDRH    R0, [R5,#0x94]\n"
                 "CMP     R0, #0\n"
                 "LDREQH  R0, [R5,#0x90]\n"
                 "CMPEQ   R0, #2\n"
                 "MOVEQ   R0, R4\n"
                 "LDMEQFD SP!, {R3-R7,LR}\n"
                 "BEQ     sub_FFC50438\n"
 "locret_FFC4F1B0:\n"
                 "LDMFD   SP!, {R3-R7,PC}\n"
    );
}


void __attribute__((naked,noinline)) sub_FFD18E4C_my(){
 asm volatile(
                 "STMFD   SP!, {R0-R8,LR}\n"
                 "MOV     R4, R0\n"
                 "BL      sub_FFD1992C\n"
                 "MVN     R1, #0\n"
                 "BL      sub_FFC58EB0\n"
                 "LDR     R5, =0x6690\n"
                 "LDR     R0, [R5,#0xC]\n"
                 "CMP     R0, #0\n"
                 "BNE     loc_FFD18E9C\n"
                 "MOV     R1, #1\n"
                 "MOV     R0, #0\n"
                 "BL      sub_FFC16DE4\n"
                 "STR     R0, [R5,#0xC]\n"
                 "MOV     R3, #0\n"
                 "STR     R3, [SP]\n"
                 "LDR     R3, =0xFFD18828\n"
                 "LDR     R0, =0xFFD190B8\n"	// aShuttersoundtask
                 "MOV     R2, #0x400\n"
                 "MOV     R1, #0x17\n"
                 "BL      sub_FFC16DB0\n"	// KernelCreateTask
 "loc_FFD18E9C:\n"
                 "MOV     R2, #4\n"
                 "ADD     R1, SP, #0x8\n"
                 "MOV     R0, #0x8A\n"
                 "BL      sub_FFC60CE0\n"	// PT_GetPropertyCaseString_0
                 "TST     R0, #1\n"
                 "LDRNE   R1, =0x3C5\n"
                 "LDRNE   R0, =0xFFD18A94\n"	// aSscaptureseq_c
                 "BLNE    sub_FFC0B048\n"	// DebugAssert
                 "LDR     R6, =0x13D58\n"
                 "LDR     R8, =0x13C94\n"
                 "LDRSH   R2, [R6,#0xC]\n"
                 "LDRSH   R1, [R6,#0xE]\n"
                 "LDR     R0, [R8,#0x8C]\n"
                 "BL      sub_FFCDE6FC\n"
                 "BL      sub_FFC39464\n"	// GetCCDTemperature
                 "LDR     R3, =0x6698\n"
                 "STRH    R0, [R4,#0xA4]\n"
                 "SUB     R2, R3, #4\n"
                 "STRD    R2, [SP]\n"
                 "MOV     R1, R0\n"
                 "LDRH    R0, [R8,#0x54]\n"
                 "LDRSH   R2, [R6,#0xC]\n"
                 "SUB     R3, R3, #8\n"
                 "BL      sub_FFD1AF5C\n"
                 "BL      wait_until_remote_button_is_released\n"	//---------->
                 "BL      capt_seq_hook_set_nr\n"			//---------->
                 "B       sub_FFD18EFC\n"		// continue function in firmware
    );
}


void __attribute__((naked,noinline)) exp_drv_task(){
    asm volatile(
		"STMFD   SP!, {R4-R8,LR}\n"
		"SUB     SP, SP, #0x20\n"
		"LDR     R8, =0xBB8\n"
		"LDR     R7, =0x3FF8\n"
		"LDR     R5, =0x18964\n"
		"MOV     R0, #0\n"
		"ADD     R6, SP, #0x10\n"
		"STR     R0, [SP,#0x0C]\n"		// var_0c = 0
 "loc_FFC86EA0:\n"
		"LDR     R0, [R7,#0x20]\n"
		"MOV     R2, #0\n"
		"ADD     R1, SP, #0x1C\n"
		"BL      sub_FFC1659C\n"
		"LDR     R0, [SP,#0x0C]\n"
		"CMP     R0, #1\n"
		"BNE     loc_FFC86EEC\n"		// var_0 != 1 ->
		"LDR     R0, [SP,#0x1C]\n"
		"LDR     R0, [R0]\n"
		"CMP     R0, #0x13\n"
		"CMPNE   R0, #0x14\n"
		"CMPNE   R0, #0x15\n"
		"CMPNE   R0, #0x16\n"
		"BEQ     loc_FFC87008\n"		// *var_1c = 0x13, 0x14, 0x15 or 0x16
		"CMP     R0, #0x28\n"
		"BEQ     loc_FFC86FE0\n"
		"ADD     R1, SP, #0x0C\n"
		"MOV     R0, #0\n"
		"BL      sub_FFC86E30\n"
 "loc_FFC86EEC:\n"
		"LDR     R0, [SP,#0x1C]\n"
		"LDR     R1, [R0]\n"
		"CMP     R1, #0x2D\n"
		"BNE     loc_FFC86F1C\n"		// if *var_1c != 0x2D (45)
		"LDR     R0, [SP,#0x1C]\n"
		"BL      sub_FFC880E8\n"
		"LDR     R0, [R7,#0x1C]\n"
		"MOV     R1, #1\n"
		"BL      sub_FFC58E7C\n"
		"BL      sub_FFC0B000\n"		// eventproc_export_ExitTask
		"ADD     SP, SP, #0x20\n"
		"LDMFD   SP!, {R4-R8,PC}\n"
 "loc_FFC86F1C:\n"	// r1 = *var_1c != 0x2D
		"CMP     R1, #0x2C\n"
		"BNE     loc_FFC86F38\n"		// if *var_1c != 0x2C (44)
		"LDR     R2, [R0,#0x8C]!\n"
		"LDR     R1, [R0,#4]\n"
		"MOV     R0, R1\n"
		"BLX     R2\n"
		"B       loc_FFC87430\n"
 "loc_FFC86F38:\n"	// r1 = *var_1c != 0x2C, 0x2D
		"CMP     R1, #0x26\n"
		"BNE     loc_FFC86F88\n"		// if *var_1c != 0x26 (38)
		"LDR     R0, [R7,#0x1C]\n"
		"MOV     R1, #0x80\n"
		"BL      sub_FFC58EB0\n"
		"LDR     R0, =0xFFC835BC\n"
		"MOV     R1, #0x80\n"
		"BL      sub_FFD0D1E0\n"
		"LDR     R0, [R7,#0x1C]\n"
		"MOV     R2, R8\n"
		"MOV     R1, #0x80\n"
		"BL      sub_FFC58DBC\n"
		"TST     R0, #1\n"
		"LDRNE   R1, =0xE54\n"			// DebugAssert
		"BNE     loc_FFC86FCC\n"		//	(ExpDrv.c:3668)
 "loc_FFC86F74:\n"
		"LDR     R1, [SP,#0x1C]\n"
		"LDR     R0, [R1,#0x90]\n"
		"LDR     R1, [R1,#0x8C]\n"
		"BLX     R1\n"				// hook?
		"B       loc_FFC87430\n"
 "loc_FFC86F88:\n"	// r1 = *var_1c != 0x26, 0x2C, 0x2D
		"CMP     R1, #0x27\n"
		"BNE     loc_FFC86FD8\n"		// if *var_1c != 0x27 (39)
		"ADD     R1, SP, #0x0C\n"
		"BL      sub_FFC86E30\n"
		"LDR     R0, [R7,#0x1C]\n"
		"MOV     R1, #0x100\n"
		"BL      sub_FFC58EB0\n"
		"LDR     R0, =0xFFC835CC\n"
		"MOV     R1, #0x100\n"
		"BL      sub_FFD0DB70\n"
		"LDR     R0, [R7,#0x1C]\n"
		"MOV     R2, R8\n"
		"MOV     R1, #0x100\n"
		"BL      sub_FFC58DBC\n"
		"TST     R0, #1\n"
		"BEQ     loc_FFC86F74\n"
		"LDR     R1, =0xE5E\n"			// DebugAssert(ExpDrv.c:3678)
 "loc_FFC86FCC:\n"
		"LDR     R0, =0xFFC83C30\n"		// "ExpDrv.c"
		"BL      sub_FFC0B048\n"		// call DebugAssert
		"B       loc_FFC86F74\n"
 "loc_FFC86FD8:\n"	// r1 = *var_1c != 0x26, 0x27, 0x2C, 0x2D
		"CMP     R1, #0x28\n"
		"BNE     loc_FFC86FF0\n"		// if *var_1c != 0x28 (40)
 "loc_FFC86FE0:\n"
		"LDR     R0, [SP,#0x1C]\n"
		"ADD     R1, SP, #0x0C\n"
		"BL      sub_FFC86E30\n"		// ExpDrv.c:512
		"B       loc_FFC86F74\n"
 "loc_FFC86FF0:\n"	// r1 = *var_1c !=  0x26, 0x27, 0x28, 0x2C, 0x2D
		"CMP     R1, #0x2B\n"
		"BNE     loc_FFC87008\n"		// if *var_1c != 0x2B (43)
		"BL      sub_FFC77038\n"		// Shutter.c:2
		"BL      sub_FFC77C5C\n"		// ImgPixel.c:272
		"BL      sub_FFC777B0\n"		// ImgGain.c:?
		"B       loc_FFC86F74\n"
// two entry points here
// first if *var_1c == 0x13, 0x14, 0x15 or 0x16
// second implies *var_1c != 0x26, 0x27, 0x28, 0x2B, 0x2C, 0x2D
 "loc_FFC87008:\n"
		"LDR     R0, [SP,#0x1C]\n"		// need to reload *var_1c
		"MOV     R4, #1\n"
		"LDR     R1, [R0]\n"
		"CMP     R1, #0x11\n"
		"CMPNE   R1, #0x12\n"
		"BNE     loc_FFC87078\n"		// if (r1 != 0x11) && (r1 != 0x12)
		"LDR     R1, [R0,#0x7C]\n"
		"ADD     R1, R1, R1,LSL#1\n"
		"ADD     R1, R0, R1,LSL#2\n"
		"SUB     R1, R1, #8\n"
		"LDMIA   R1, {R2-R4}\n"
		"STMIA   R6, {R2-R4}\n"
		"BL      sub_FFC85798\n"		//2check (?)
		"LDR     R0, [SP,#0x1C]\n"
		"LDR     R1, [R0,#0x7C]\n"
		"LDR     R3, [R0,#0x8C]\n"
		"LDR     R2, [R0,#0x90]\n"
		"ADD     R0, R0, #4\n"
		"BLX     R3\n"
		"LDR     R0, [SP,#0x1C]\n"
		"BL      sub_FFC884AC\n"		// ExpDrv.c:?
		"LDR     R0, [SP,#0x1C]\n"
		"LDR     R1, [R0,#0x7C]\n"
		"LDR     R3, [R0,#0x94]\n"
		"LDR     R2, [R0,#0x98]\n"
		"ADD     R0, R0, #4\n"
		"BLX     R3\n"				// Call some hooked whatever?
		"B       loc_FFC87370\n"
 "loc_FFC87078:\n"	// *var_1c != 0x11, 0x12, 0x26, 0x27, 0x28, 0x2B, 0x2C, 0x2D
		"CMP     R1, #0x13\n"
		"CMPNE   R1, #0x14\n"
		"CMPNE   R1, #0x15\n"
		"CMPNE   R1, #0x16\n"
		"BNE     loc_FFC87130\n"		// if r1 != 0x13, 0x14, 0x15, 0x16
		"ADD     R3, SP, #0x0C\n"
		"MOV     R2, SP\n"
		"ADD     R1, SP, #0x10\n"
		"BL      sub_FFC85A80\n"		// ExpDrv.c:?
		"CMP     R0, #1\n"
		"MOV     R4, R0\n"
		"CMPNE   R4, #5\n"
		"BNE     loc_FFC870CC\n"
		"LDR     R0, [SP,#0x1C]\n"
		"MOV     R2, R4\n"
		"LDR     R1, [R0,#0x7C]!\n"
		"LDR     R12, [R0,#0x10]!\n"
		"LDR     R3, [R0,#4]\n"
		"MOV     R0, SP\n"
		"BLX     R12\n"			// Another hook?
		"B       loc_FFC87104\n"
 "loc_FFC870CC:\n"
		"LDR     R0, [SP,#0x1C]\n"
		"CMP     R4, #2\n"
		"LDR     R3, [R0,#0x90]\n"
		"CMPNE   R4, #6\n"
		"BNE     loc_FFC87118\n"
		"LDR     R12, [R0,#0x8C]\n"
		"MOV     R0, SP\n"
		"MOV     R2, R4\n"
		"MOV     R1, #1\n"
		"BLX     R12\n"
		"LDR     R0, [SP,#0x1C]\n"
		"MOV     R2, SP\n"
		"ADD     R1, SP, #0x10\n"
		"BL      sub_FFC86B38\n"		// ExpDrv.c:?
 "loc_FFC87104:\n"
		"LDR     R0, [SP,#0x1C]\n"
		"LDR     R2, [SP,#0x0C]\n"
		"MOV     R1, R4\n"
		"BL      sub_FFC86DD0\n"		// ExpDrv.c:2
		"B       loc_FFC87370\n"
 "loc_FFC87118:\n"
		"LDR     R1, [R0,#0x7C]\n"
		"LDR     R12, [R0,#0x8C]\n"
		"ADD     R0, R0, #4\n"
		"MOV     R2, R4\n"
		"BLX     R12\n"			// Some hook
		"B       loc_FFC87370\n"
 "loc_FFC87130:\n"	// *var_1c != 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x26, 0x27, 0x28, 0x2B, 0x2C, 0x2D
		"CMP     R1, #0x22\n"
		"CMPNE   R1, #0x23\n"
		"BNE     loc_FFC8717C\n"		// jump table, if r1 != 0x22, 0x23
		"LDR     R1, [R0,#0x7C]\n"
		"ADD     R1, R1, R1,LSL#1\n"
		"ADD     R1, R0, R1,LSL#2\n"
		"SUB     R1, R1, #8\n"
		"LDMIA   R1, {R2-R4}\n"
		"STMIA   R6, {R2-R4}\n"
		"BL      sub_FFC84CDC\n"		// ExpDrv.c:?
		"LDR     R0, [SP,#0x1C]\n"
		"LDR     R1, [R0,#0x7C]\n"
		"LDR     R3, [R0,#0x8C]\n"
		"LDR     R2, [R0,#0x90]\n"
		"ADD     R0, R0, #4\n"
		"BLX     R3\n"
		"LDR     R0, [SP,#0x1C]\n"
		"BL      sub_FFC84FDC\n"		// ExpDrv.c:?
		"B       loc_FFC87370\n"
 "loc_FFC8717C:\n"	// *var_1c != 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x22, 0x23, 0x26, 0x27, 0x28, 0x2B, 0x2C, 0x2D
		"ADD     R1, R0, #4\n"
		"LDMIA   R1, {R2,R3,R12}\n"
		"STMIA   R6, {R2,R3,R12}\n"
		"LDR     R1, [R0]\n"			// r1 is now var_1c from (loc_FFC87008)
		"CMP     R1, #0x25\n"
		"ADDLS   PC, PC, R1,LSL#2\n"		// Jump around in jump table, 38 entries (0-37)
//------------------------ Start of jump table ------------------------
// Do NOT modify this lines unless you really know what you are doing!
		"B       loc_FFC87350\n"		// 0
 "loc_FFC87198:\n"
		"B       loc_FFC87230\n"		// 1
 "loc_FFC8719C:\n"
		"B       loc_FFC87230\n"		// 2
 "loc_FFC871A0:\n"
		"B       loc_FFC87238\n"		// 3
 "loc_FFC871A4:\n"
		"B       loc_FFC87240\n"		// 4
 "loc_FFC871A8:\n"
		"B       loc_FFC87240\n"		// 5
 "loc_FFC871AC:\n"
		"B       loc_FFC87240\n"		// 6
 "loc_FFC871B0:\n"
		"B       loc_FFC87230\n"		// 7
 "loc_FFC871B4:\n"
		"B       loc_FFC87238\n"		// 8
 "loc_FFC871B8:\n"
		"B       loc_FFC87240\n"		// 9
 "loc_FFC871BC:\n"
		"B       loc_FFC87240\n"		// 10
 "loc_FFC871C0:\n"
		"B       loc_FFC87258\n"		// 11 
 "loc_FFC871C4:\n"
		"B       loc_FFC87258\n"		// 12
 "loc_FFC871C8:\n"
		"B       loc_FFC87344\n"		// 13
 "loc_FFC871CC:\n"
		"B       loc_FFC8734C\n"		// 14
 "loc_FFC871D0:\n"
		"B       loc_FFC8734C\n"		// 15
 "loc_FFC871D4:\n"
		"B       loc_FFC8734C\n"		// 16
 "loc_FFC871D8:\n"
		"B       loc_FFC8734C\n"		// 17 (never called?)
 "loc_FFC871DC:\n"
		"B       loc_FFC87350\n"		// 18 (never called?)
 "loc_FFC871E0:\n"
		"B       loc_FFC87350\n"		// 19 (never called?)
 "loc_FFC871E4:\n"
		"B       loc_FFC87350\n"		// 20 (never called?)
 "loc_FFC871E8:\n"
		"B       loc_FFC87350\n"		// 21 (never called?)
 "loc_FFC871EC:\n"
		"B       loc_FFC87350\n"		// 22 (never called?)
 "loc_FFC871F0:\n"
		"B       loc_FFC87350\n"		// 23
 "loc_FFC871F4:\n"
		"B       loc_FFC87248\n"		// 24
 "loc_FFC871F8:\n"
		"B       loc_FFC87250\n"		// 25
 "loc_FFC871FC:\n"
		"B       loc_FFC87250\n"		// 26
 "loc_FFC87200:\n"
		"B       loc_FFC87264\n"		// 27
 "loc_FFC87204:\n"
		"B       loc_FFC87264\n"		// 28
 "loc_FFC87208:\n"
		"B       loc_FFC8726C\n"		// 29
 "loc_FFC8720C:\n"
		"B       loc_FFC8729C\n"		// 30
 "loc_FFC87210:\n"
		"B       loc_FFC872CC\n"		// 31
 "loc_FFC87214:\n"
		"B       loc_FFC872FC\n"		// 32
 "loc_FFC87218:\n"
		"B       loc_FFC8732C\n"		// 33
 "loc_FFC8721C:\n"
		"B       loc_FFC8732C\n"		// 34 (never called?)
 "loc_FFC87220:\n"
		"B       loc_FFC87350\n"		// 35 (never called?)
 "loc_FFC87224:\n"
		"B       loc_FFC87350\n"		// 36
 "loc_FFC87228:\n"
		"B       loc_FFC87334\n"		// 37
 "loc_FFC8722C:\n"
		"B       loc_FFC8733C\n"		// 38
//------------------------- End of jump table -------------------------
 "loc_FFC87230:\n"	// 0, 1, 6
		"BL      sub_FFC83AD4\n"		// ExpDrv.c:2
		"B       loc_FFC87350\n"
 "loc_FFC87238:\n"	// 2, 7
		"BL      sub_FFC83D5C\n"		// ExpDrv.c:?
		"B       loc_FFC87350\n"
 "loc_FFC87240:\n"	// 3 - 5, 8, 9
		"BL      sub_FFC83F64\n"		// ExpDrv.c:?
		"B       loc_FFC87350\n"
 "loc_FFC87248:\n"	// 23
		"BL      sub_FFC841DC\n"		// ExpDrv.c:2
		"B       loc_FFC87350\n"
 "loc_FFC87250:\n"	// 24, 25
		"BL      sub_FFC843D4\n"		// ExpDrv.c:?
		"B       loc_FFC87350\n"
 "loc_FFC87258:\n"	// 10, 11
		"BL      sub_FFC84690_my\n"		//----------------->
		"MOV     R4, #0\n"			// R4 = 0
		"B       loc_FFC87350\n"
 "loc_FFC87264:\n"	// 26, 27
		"BL      sub_FFC847D0\n"		// ExpDrv.c:0
		"B       loc_FFC87350\n"
 "loc_FFC8726C:\n"	// 28
		"LDRH    R1, [R0,#4]\n"
		"STRH    R1, [SP,#0x10]\n"
		"LDRH    R1, [R5,#2]\n"
		"STRH    R1, [SP,#0x12]\n"
		"LDRH    R1, [R5,#4]\n"
		"STRH    R1, [SP,#0x14]\n"
		"LDRH    R1, [R5,#6]\n"
		"STRH    R1, [SP,#0x16]\n"
		"LDRH    R1, [R0,#0xC]\n"
		"STRH    R1, [SP,#0x18]\n"
		"BL      sub_FFC8815C\n"		// ExpDrv.c:2
		"B       loc_FFC87350\n"
 "loc_FFC8729C:\n"	// 29
		"LDRH    R1, [R0,#4]\n"
		"STRH    R1, [SP,#0x10]\n"
		"LDRH    R1, [R5,#2]\n"
		"STRH    R1, [SP,#0x12]\n"
		"LDRH    R1, [R5,#4]\n"
		"STRH    R1, [SP,#0x14]\n"
		"LDRH    R1, [R5,#6]\n"
		"STRH    R1, [SP,#0x16]\n"
		"LDRH    R1, [R5,#8]\n"
		"STRH    R1, [SP,#0x18]\n"
		"BL      sub_FFC882C4\n"		// 
		"B       loc_FFC87350\n"
 "loc_FFC872CC:\n"	// 30
		"LDRH    R1, [R5]\n"
		"STRH    R1, [SP,#0x10]\n"
		"LDRH    R1, [R0,#6]\n"
		"STRH    R1, [SP,#0x12]\n"
		"LDRH    R1, [R5,#4]\n"
		"STRH    R1, [SP,#0x14]\n"
		"LDRH    R1, [R5,#6]\n"
		"STRH    R1, [SP,#0x16]\n"
		"LDRH    R1, [R5,#8]\n"
		"STRH    R1, [SP,#0x18]\n"
		"BL      sub_FFC88370\n"
		"B       loc_FFC87350\n"
 "loc_FFC872FC:\n"	// 31
		"LDRH    R1, [R5]\n"
		"STRH    R1, [SP,#0x10]\n"
		"LDRH    R1, [R5,#2]\n"
		"STRH    R1, [SP,#0x12]\n"
		"LDRH    R1, [R5,#4]\n"
		"STRH    R1, [SP,#0x14]\n"
		"LDRH    R1, [R5,#6]\n"
		"STRH    R1, [SP,#0x16]\n"
		"LDRH    R1, [R0,#0xC]\n"
		"STRH    R1, [SP,#0x18]\n"
		"BL      sub_FFC88410\n"
		"B       loc_FFC87350\n"
 "loc_FFC8732C:\n"	// 32, 33
		"BL      sub_FFC84B18\n"
		"B       loc_FFC87350\n"
 "loc_FFC87334:\n"	// 36
		"BL      sub_FFC850E0\n"
		"B       loc_FFC87350\n"
 "loc_FFC8733C:\n"	// 37
		"BL      sub_FFC8531C\n"
		"B       loc_FFC87350\n"
 "loc_FFC87344:\n"	// 12
		"BL      sub_FFC85498\n"
		"B       loc_FFC87350\n"
 "loc_FFC8734C:\n"	// 13 - 16
		"BL      sub_FFC85634\n"
 "loc_FFC87350:\n"	// (17 - 22), (34), (35). Entries continue here.
		"LDR     R0, [SP,#0x1C]\n"
		"LDR     R1, [R0,#0x7C]\n"
		"LDR     R3, [R0,#0x8C]\n"
		"LDR     R2, [R0,#0x90]\n"
		"ADD     R0, R0, #4\n"
		"BLX     R3\n"
		"CMP     R4, #1\n"
		"BNE     loc_FFC873B8\n"
 "loc_FFC87370:\n"
		"LDR     R0, [SP,#0x1C]\n"
		"MOV     R2, #0xC\n"
		"LDR     R1, [R0,#0x7C]\n"
		"ADD     R1, R1, R1,LSL#1\n"
		"ADD     R0, R0, R1,LSL#2\n"
		"SUB     R4, R0, #8\n"
		"LDR     R0, =0x18964\n"
		"ADD     R1, SP, #0x10\n"
		"BL      sub_FFE90B58\n"
		"LDR     R0, =0x18970\n"
		"MOV     R2, #0xC\n"
		"ADD     R1, SP, #0x10\n"
		"BL      sub_FFE90B58\n"
		"LDR     R0, =0x1897C\n"
		"MOV     R2, #0xC\n"
		"MOV     R1, R4\n"
		"BL      sub_FFE90B58\n"
		"B       loc_FFC87430\n"
 "loc_FFC873B8:\n"
		"LDR     R0, [SP,#0x1C]\n"
		"LDR     R0, [R0]\n"
		"CMP     R0, #0xB\n"
		"BNE     loc_FFC87400\n"
		"MOV     R3, #0\n"
		"STR     R3, [SP]\n"
		"MOV     R3, #1\n"
		"MOV     R2, #1\n"
		"MOV     R1, #1\n"
		"MOV     R0, #0\n"
		"BL      sub_FFC838DC\n"
		"MOV     R3, #0\n"
		"STR     R3, [SP]\n"
		"MOV     R3, #1\n"
		"MOV     R2, #1\n"
		"MOV     R1, #1\n"
		"MOV     R0, #0\n"
		"B       loc_FFC8742C\n"
 "loc_FFC87400:\n"
		"MOV     R3, #1\n"
		"MOV     R2, #1\n"
		"MOV     R1, #1\n"
		"MOV     R0, #1\n"
		"STR     R3, [SP]\n"
		"BL      sub_FFC838DC\n"
		"MOV     R3, #1\n"
		"MOV     R2, #1\n"
		"MOV     R1, #1\n"
		"MOV     R0, #1\n"
		"STR     R3, [SP]\n"
 "loc_FFC8742C:\n"
		"BL      sub_FFC83A1C\n"
 "loc_FFC87430:\n"
		"LDR     R0, [SP,#0x1C]\n"
		"BL      sub_FFC880E8\n"
		"B       loc_FFC86EA0\n" 
    );
}

void __attribute__((naked,noinline)) sub_FFC84690_my(){
    asm volatile(
		"STMFD   SP!, {R4-R8,LR}\n"
		"LDR     R7, =0x3FF8\n"
		"MOV     R4, R0\n"
		"LDR     R0, [R7,#0x1C]\n"
		"MOV     R1, #0x3E\n"
		"BL      sub_FFC58EB0\n"
		"LDRSH   R0, [R4,#4]\n"
		"MOV     R2, #0\n"
		"MOV     R1, #0\n"
		"BL      sub_FFC83640\n"
		"MOV     R6, R0\n"
		"LDRSH   R0, [R4,#6]\n"
		"BL      sub_FFC83750\n"
		"LDRSH   R0, [R4,#8]\n"
		"BL      sub_FFC837A8\n"
		"LDRSH   R0, [R4,#0xA]\n"
		"BL      sub_FFC83800\n"
		"LDRSH   R0, [R4,#0xC]\n"
		"MOV     R1, #0\n"
		"BL      sub_FFC83858\n"
		"MOV     R5, R0\n"
		"LDR     R0, [R4]\n"
		"LDR     R8, =0x1897C\n"
		"CMP     R0, #0xB\n"
		"MOVEQ   R6, #0\n"
		"MOVEQ   R5, #0\n"
		"BEQ     loc_FFC84724\n"
		"CMP     R6, #1\n"
		"BNE     loc_FFC84724\n"
		"LDRSH   R0, [R4,#4]\n"
		"LDR     R1, =0xFFC835AC\n"
		"MOV     R2, #2\n"
		"BL      sub_FFD0D52C\n"
		"STRH    R0, [R4,#4]\n"
		"MOV     R0, #0\n"
		"STR     R0, [R7,#0x28]\n"
		"B       loc_FFC8472C\n"
 "loc_FFC84724:\n"
		"LDRH    R0, [R8]\n"
		"STRH    R0, [R4,#4]\n"
 "loc_FFC8472C:\n"
		"CMP     R5, #1\n"
		"LDRNEH  R0, [R8,#8]\n"
		"BNE     loc_FFC84748\n"
		"LDRSH   R0, [R4,#0xC]\n"
		"LDR     R1, =0xFFC83630\n"
		"MOV     R2, #0x20\n"
		"BL      sub_FFC88118\n"
 "loc_FFC84748:\n"
		"STRH    R0, [R4,#0xC]\n"
		"LDRSH   R0, [R4,#6]\n"
		"BL      sub_FFC76DA8_my\n"		//---------------->
		"LDRSH   R0, [R4,#8]\n"
		"MOV     R1, #1\n"
		"BL      sub_FFC774F8\n"
		"MOV     R1, #0\n"
		"ADD     R0, R4, #8\n"
		"BL      sub_FFC77580\n"
		"LDRSH   R0, [R4,#0xE]\n"
		"BL      sub_FFC7F100\n"
		"LDR     R4, =0xBB8\n"
		"CMP     R6, #1\n"
		"BNE     loc_FFC847A0\n"
		"LDR     R0, [R7,#0x1C]\n"
		"MOV     R2, R4\n"
		"MOV     R1, #2\n"
		"BL      sub_FFC58DBC\n"
		"TST     R0, #1\n"
		"SUBNE   R1, R4, #0x620\n"
		"LDRNE   R0, =0xFFC83C30\n"		// "ExpDrv.c"
		"BLNE    sub_FFC0B048\n"		// DebugAssert
 "loc_FFC847A0:\n"
		"CMP     R5, #1\n"
		"LDMNEFD SP!, {R4-R8,PC}\n"
		"LDR     R0, [R7,#0x1C]\n"
		"MOV     R2, R4\n"
		"MOV     R1, #0x20\n"
		"BL      sub_FFC58DBC\n"
		"TST     R0, #1\n"
		"LDRNE   R1, =0x59D\n"
		"LDRNE   R0, =0xFFC83C30\n"		// aExpdrv_c
		"LDMNEFD SP!, {R4-R8,LR}\n"
		"BNE     sub_FFC0B048\n"		// DebugAssert
		"LDMFD   SP!, {R4-R8,PC}\n"
    );
}


void __attribute__((naked,noinline)) sub_FFC76DA8_my(){
    asm volatile(
		"STMFD   SP!, {R4-R6,LR}\n"
		"LDR     R5, =0x3D08\n"
		"MOV     R4, R0\n"
		"LDR     R0, [R5,#4]\n"
		"CMP     R0, #1\n"
		"LDRNE   R1, =0x146\n"
		"LDRNE   R0, =0xFFC76BAC\n"
		"BLNE    sub_FFC0B048\n"		// DebugAssert(Shutter.c:326)
		"CMN     R4, #0xC00\n"
		"LDREQSH R4, [R5,#2]\n"
		"CMN     R4, #0xC00\n"
		"MOVEQ   R1, #0x14C\n"
		"LDREQ   R0, =0xFFC76BAC\n"
		"STRH    R4, [R5,#2]\n"
		"BLEQ    sub_FFC0B048\n"		// DebugAssert(Shutter.c:332)
		"MOV     R0, R4\n"
		"BL      apex2us\n"			// changed (call our own apex2us)
		"MOV     R4, R0\n"
		//"BL      nullsub_65\n"		// removed (null sub)
		"MOV     R0, R4\n"
		"BL      sub_FFCB0998\n"
		"TST     R0, #1\n"
		"LDRNE   R1, =0x151\n"
		"LDMNEFD SP!, {R4-R6,LR}\n"
		"LDRNE   R0, =0xFFC76BAC\n"
		"BNE     sub_FFC0B048\n"		// DebugAssert(Shutter.c:337)
		"LDMFD   SP!, {R4-R6,PC}\n"
);
}
